package com.hsq.file_;

import java.io.FileOutputStream;
import java.io.IOException;

public class WriteFile {
    public static void main(String[] args) {
        byte buffer[] = new byte[128];
        System.out.println("请输入数据，回车后保存到文件D:\\git_turtle\\news1.txt");
        System.out.println("输入“#”则退出");
        try {
            FileOutputStream f = new FileOutputStream("D:\\git_turtle\\news1.txt");
            while (true){
                int n = System.in.read(buffer);
                if (buffer[0] == '#'){
                    break;
                }
                f.write(buffer);
                f.write('\n');
            }
            f.close();
        } catch (IOException e) {
            System.out.println(e.toString());
        }

    }
}
